package com.lovemanai.service.impl;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.lovemanai.service.Axe;
import com.lovemanai.service.Person;

public class Chinese implements Person, InitializingBean, 
	BeanNameAware, ApplicationContextAware, DisposableBean{

	private Axe axe;
	
	public void setAxe(Axe axe) {
		System.out.println("Spring调用setAxe()执行依赖注入....");
		this.axe = axe;
	}

	
	public Chinese() {
		System.out.println("Spring实例化bean：Chinese实例....");
	}

	/*
	 * 初始化方法
	 */
	public void init() {
		System.out.println("正在执行初始化方法init.....");
	}

	
	public void useAxe() {
		
		axe.chop();
	}

	/*
	 * 实现InitializingBean接口默认初始化方法
	 * (non-Javadoc)
	 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
	 */
	@Override
	public void afterPropertiesSet() throws Exception {
		
		System.out.println("正在执行初始化方法afterPropertiesSet.....");
	}

	@Override
	public void setApplicationContext(ApplicationContext arg0)
			throws BeansException {
		
		System.out.println("----setApplicationContext----");
		
	}

	@Override
	public void setBeanName(String arg0) {
		
		System.out.println("----setBeanName----");
		
	}

	
	/*
	 * bean销毁之前执行的方法
	 */
	public void close() {
		
		System.out.println("正在执行销毁之前的方法close.....");
		
	}
	
	/*
	 * 实现DisposableBean接口的默认bean销毁之前执行的方法
	 */
	@Override
	public void destroy() throws Exception {
		System.out.println("正在执行销毁之前的方法destroy....");
		
	}


	@Override
	public void hunt() {
		// TODO Auto-generated method stub
		
	}

}
